import Vue from 'vue'
import Vuex from 'vuex'
import  user from  "./user";

Vue.use(Vuex)

export default new Vuex.Store({
  state: {//全局的数据
    num:10
  },
  getters: {//全局的计算属性
  },
  mutations: {//全局的同步方法
     changeNum(state,n){
      state.num  = state.num+n;
     }

  },
  actions: { //全局的异步方法
    asyncChangeNum(context,n){
        setTimeout(() => {
          context.commit("changeNum",n);
        }, 1000);
    }
  },
  modules: {//模块
    user
  }
})
